package com.kob.design.singleton.hungry;

import com.kob.design.singleton.hungry.Singleton1;
import com.kob.design.singleton.hungry.Singleton2;

/**
 * @Description: TODO
 * @Author: fyt
 * @Date: 2024/4/15 18:12
 **/
public class Client {
    public static void main(String[] args) {
        // 饿汉式:静态成员变量测试
        Singleton1 singleton1 = Singleton1.getInstance();
        Singleton1 singleton11 = Singleton1.getInstance();
        System.out.println(singleton11);
        System.out.println(singleton1);

        // 饿汉式: 静态成员变量
        Singleton2 singleton22 = Singleton2.getInstance();
        Singleton2 singleton2 = Singleton2.getInstance();
        System.out.println(singleton2);
        System.out.println(singleton22);

        // 饿汉式: 枚举
        Singleton3 singleton3 = Singleton3.INSTANCE;
        Singleton3 singleton33 = Singleton3.INSTANCE;
        System.out.println(singleton3 == singleton33);
    }
}
